<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<c:if test="${ empty title }">
	<c:set scope="request" var="title" value="用户详情"></c:set>
</c:if>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>${ title }</title>
    <base href="${ pageContext.servletContext.contextPath }/">
    <link rel="icon" href="statics/img/favicon.svg" sizes="any" type="image/svg+xml">
    <link rel="stylesheet" href="statics/css/base.css">
    <link rel="stylesheet" href="statics/css/form.css">
</head>
<body>
    <%@include file="/pages/common/header.jsp"%>
    <!-- 主体 -->
    <main class="flex-center">
        <form method="POST">
            <p class="tips ${ empty message ? 'hide' : '' }"> 
                <img src="statics/img/灯泡.png">
                <span>${ message }</span>
            </p>
            <input type="hidden" name="id" value="${ user.id }">
            <input type="hidden" name="referer" value="${ header.Referer }">
            <p>
            	<label class="text-right">用户名：</label>
            	<input type="text" name="username" value="${ user.username }" placeholder="请输入用户名">
           	</p>
            <p>
            	<label class="text-right">年龄：</label>
            	<input type="number" name="age" value="${ user.age }" placeholder="请输入年龄" min="0" max="120">
           	</p>
            <p>
            	<label class="text-right">性别：</label>
            	<input type="radio" id="man" name="gender" value="0" ${ user.gender == 0 ? 'checked="checked"' : '' }>
            	<label for="man">男</label>
            	<input type="radio" id="woman" class="ml-20px" name="gender" value="1" ${ user.gender == 1 ? 'checked="checked"' : '' }>
            	<label for="woman">女</label>
           	</p>
            <p>
            	<label class="text-right">邮箱：</label>
            	<input type="text" name="email" value="${ user.email }" placeholder="请输入新邮箱"/>
           	</p>
            <p>
            	<label class="text-right">注册时间：</label>
            	<c:if test="${ not empty user.createTime }">
	            	<input type="hidden" name="createTime" value="<fmt:formatDate value="${ user.createTime }" pattern="yyyy-MM-dd HH:mm:ss"/>" />
	            	<input type="text" value="<fmt:formatDate value="${ user.createTime }" pattern="yyyy-MM-dd HH:mm:ss"/>" disabled="disabled">
            	</c:if>
            	<c:if test="${ empty user.createTime }">
            		<input type="hidden" name="createTime" value="${ param.createTime }" />
            		<input type="text" value="${ param.createTime }" disabled="disabled">
            	</c:if>
            </p>
            <c:if test="${ requestScope.user.id == sessionScope.loginUser.id }">
	            <p class="hide new-password">
	            	<label class="text-right">新密码：</label>
	            	<input type="password" name="password" placeholder="请输入新密码" />
	           	</p>
           	</c:if>
            <p><button class="btn btn-success w-100">提交修改</button></p>
            <c:if test="${ requestScope.user.id == sessionScope.loginUser.id }">
            	<p><button type="button" class="btn w-100 update-password">修改密码</button></p>
            </c:if>
        </form>
    </main>
    <%@include file="/pages/common/footer.jsp" %>
    
    <script src="statics/js/common.js"></script>
    <script src="statics/js/form.js"></script>
    <script src="statics/js/message_box.js"></script>
    <script src="statics/js/user.js"></script>
</body>
</html>